FROM 120.53.220.252:7654/library/golang:1.23.3_amd64 as builder
ARG tags
ARG build_os
ARG build_arch

WORKDIR /app/build 
COPY . .
ENV GO_BUILD_TAG=${tags}
ENV GO_BUILD_OS=${build_os}
ENV GO_BUILD_ARCH=${build_arch}

RUN go env -w GOPROXY=https://goproxy.cn,direct \
    && go env -w CGO_ENABLED=0  \
    && go env -w GOOS=linux  \
    && go env -w GOARCH=amd64 \
    && go mod tidy \ 
    && env \
    && sh -c  "go build -tags $GO_BUILD_TAG -o ./srAdmin ./main.go" \
    && ./srAdmin list 

FROM 120.53.220.252:7654/library/alpine:amd64 

ENV GOPROXY=https://goproxy.cn
ENV TZ=Asia/Shanghai

# RUN  echo "http://mirrors.aliyun.com/alpine/v3.4/main/" > /etc/apk/repositories \
#     && apk --no-cache add tzdata zeromq \
#     && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
#     && echo '$TZ' > /etc/timezone



WORKDIR /app
COPY --from=builder /app/build/srAdmin /usr/local/bin/srAdmin
COPY --from=builder /app/build/etc/config.yaml /etc/sr/config.yaml
# COPY --from=builder /app/build/etc/lng /etc/sr/lng

EXPOSE 8080
RUN  chmod 755 /usr/local/bin/srAdmin
CMD ["srAdmin","server","-c", "/etc/sr/config.yaml"]